<template>
	<view class="pageBox" :style="{paddingTop: statusBarHeight + 44 + 'px',}">
		<view class="topHead flex-between" :style="{top: statusBarHeight + 'px',}">
			<uni-icons type="back" size="24" @click="goBack"></uni-icons>
			<view class="title">
				我的推广
			</view>
			<view class="right">
				转赠次数：{{user.issued_give}}次
			</view>
		</view>

		<view class="topBox">
			<view class="top flex">
				<image class="avatar" :src="user.avatar" mode=""></image>
				<view class="nickname flex-between">
					<view class="nicknameText">
						{{user.account}}
					</view>
					<view class="level">
						{{user.serviceLevelName}}
					</view>
				</view>

				<view class="performance">
					<view class="performanceText flex-center">
						总业绩（元）
					</view>
					<view class="performanceNum flex-center">
						{{ Number(user.performanceAll).toFixed(2) }}元
					</view>
				</view>

				<view class="team flex-between">
					<view class="teamItem flex-center">
						<view class="teamItemText">
							团队人数：
						</view>
						<view class="teamItemNum">
							{{user.teamNum}}
						</view>
						<view class="teamItemText">
							人
						</view>
					</view>
					<view class="teamLine">

					</view>
					<view class="teamItem flex-center">
						<view class="teamItemText">
							团队业绩：
						</view>
						<view class="teamItemNum">
							{{Number(user.performanceTeam).toFixed(2)}}
						</view>
					</view>
				</view>
			</view>
		</view>






		<view class="listTitle">
			分享列表
		</view>
		<view class="list">

			<view class="listItem" v-for="item in list" :key="item.id">
				<view class="item">
					姓名：{{ item.nickname }}
				</view>
				<view class="item">
					手机号：{{ item.account }}
				</view>
				<view class="item">
					个人业绩：{{ item.performance }}
				</view>

				<view class="vip">
					<view class="vipTop">
						{{ item.level_name }}
					</view>
					<view class="vipBom" v-if="item.levelValid == 1&&item.level==2">
						有效
					</view>
					<view class="vipBom2" v-if="item.levelValid == 0&&item.level==2">
						失效
					</view>
				</view>
			</view>
		</view>
		<u-loadmore :status="status" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBarHeight: "",

				lastId: 0,
				page: 1,
				list: [],
				end: false,
				status: 'loadmore',
				user: {}
			}
		},
		onLoad() {
			this.statusBarHeight = this.$mySysInfo().top;
		},
		onShow() {
			this.getTeamList()
		},
		onReachBottom() {
			this.getTeamList()
		},
		methods: {
			getTeamList() {
				if (this.end) {
					return
				}
				this.$post({
					module: 'User',
					interface: 4101,
					data: {
						lastId: this.lastId,
						page: this.page,
						floor: 1
					}
				}).then(res => {
					// console.log(res);
					this.user = res.userInfo;
					this.list = [...this.list, ...res.list]
					if (res.list.length < 10) {
						this.end = true
					}
					if (res.list.length < 10) {
						this.status = 'nomore';
					} else {
						this.status = 'loading';
					}
					this.page++
					this.lastId = res.lastId
				})
			},
			goBack() {
				const pages = getCurrentPages()
				if (pages.length === 1) {
					if (typeof params === 'number') {
						history.go(-params)
					} else {
						history.back()
					}
				} else {
					uni.navigateBack({
						delta: 1
					});
				}
			},
		},
	}
</script>

<style scoped lang="scss">
	.pageBox {
		width: 100%;
		min-height: 100vh;
		background-color: #F9F9F9;

		.topHead {
			background-color: #ffffff;
			height: 88rpx;
			width: 100%;
			padding: 0 32rpx;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 3;

			.title {
				font-size: 32rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #000000;
				position: absolute;
				top: 22rpx;
				left: 50%;
				transform: translate(-50%, 0);
			}

			.right {
				font-size: 24rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #F2615F;
			}
		}

		.topBox {
			width: 100%;
			height: 386rpx;
			padding: 94rpx 30rpx 0;
			background-image: url("http://www.bobei.shop/static/third/topHeadBg.png");
			background-repeat: no-repeat;
			background-size: 100% 324rpx;

			.top {
				width: 100%;
				height: 292rpx;
				background: #FFFFFF;
				box-shadow: 0px 4rpx 8rpx 0px rgba(212, 212, 212, 0.25);
				border-radius: 24rpx 24rpx 24rpx 24rpx;
				position: relative;
				padding-top: 24rpx;
				flex-direction: column;

				.avatar {
					width: 120rpx;
					height: 120rpx;
					border: 4rpx solid #FFFFFF;
					border-radius: 50%;
					position: absolute;
					top: -60rpx;
					left: 0;
					z-index: 1;
				}

				.nickname {
					padding: 0 30rpx 0 144rpx;

					.nicknameText {
						font-size: 32rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #000000;
					}

					.level {
						font-size: 16rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #F2615F;
						padding: 4rpx 14rpx;
						border-radius: 4rpx 4rpx 4rpx 4rpx;
						border: 1px solid #FB673D;
					}
				}

				.performance {
					margin-top: 40rpx;

					.performanceText {
						font-size: 36rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #000000;
					}

					.performanceNum {
						font-size: 32rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #F2615F;
					}
				}

				.team {
					width: 100%;
					margin-top: 24rpx;

					.teamItem {
						width: 49%;

						.teamItemText {
							font-size: 24rpx;
							font-family: PingFang SC-Regular, PingFang SC;
							font-weight: 400;
							color: #000000;
						}

						.teamItemNum {
							font-size: 24rpx;
							font-family: PingFang SC-Regular, PingFang SC;
							font-weight: 400;
							color: #F2615F;
						}
					}

					.teamLine {
						width: 2rpx;
						height: 26rpx;
						background-color: #C6C6C6;
					}
				}
			}
		}



		.listTitle {
			font-size: 36rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: bold;
			color: #000000;
			line-height: 40rpx;
			margin-top: 32rpx;
			padding-left: 32rpx;
		}

		.list {
			padding: 24rpx 30rpx;

			.listItem {
				margin-bottom: 24rpx;
				padding: 12rpx 32rpx;
				position: relative;
				background: #FFFFFF;
				box-shadow: 0px 4rpx 8rpx 0px rgba(212, 212, 212, 0.25);
				border-radius: 24rpx 8rpx 24rpx 24rpx;

				.item {
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #000000;
					line-height: 44rpx;
					margin: 20rpx 0;
				}

				.vip {
					position: absolute;
					top: 32rpx;
					right: 32rpx;
					z-index: 1;

					.vipTop {
						font-size: 24rpx;
						font-family: PingFangSC-Semibold, PingFang SC;
						font-weight: 600;
						color: #F2615F;
						line-height: 44rpx;
					}

					.vipBom {
						font-size: 20rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #000000;
						line-height: 44rpx;
					}

					.vipBom2 {
						font-size: 20rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						line-height: 44rpx;
					}
				}
			}
		}
	}
</style>
